<%@page import="com.jredu.entity.User"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/res/css/style.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/res/css/skin_/table.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/web/themes/gray/easyui.css">
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/web/themes/icon.css">
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/res/css/skin_/form.css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/web/jquery.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/web/jquery.easyui.min.js"></script>

<title>表格</title>
</head>

<body>
<div id="container">
	<div id="hd"></div>
    <div id="bd">
    	<div id="main">
        	<div class="search-box ue-clear">
            	<div class="search-area">
                   
                    <div class="kv-item ue-clear">
                        <label>角色名称:</label>
                        <div class="kv-item-content">
                            <input type="text" name="roleName" id="roleName"/>
                        </div>
                    </div>
                </div>
                <div class="search-button" style="margin-left:20px">
                	<input class="button" type="button" value="搜索" />
                </div>
             </div>
             
            <div class="table">
            	<div class="opt ue-clear">
                	
                	<span class="optarea">
                        <a href="javascript:;" class="add">
                            <i class="icon"></i>
                            <span class="text">添加</span>
                        </a>
                        <a href="javascript:;" class="delete">
                            <i class="icon"></i>
                            <span class="text">删除</span>
                        </a>
                        
                        
                    </span>
                </div>
             	<div id="grid"></div>
             	<div class="pagination"></div>
            </div>
        </div>
    </div>
</div>

<div id="dd">
	<div id="container">
    <div id="bd">
    	<input type="hidden" name='reqCode' value='addRole'/>
    	<div id="main">
            <h2 class="subfild">
            	<span>课程信息</span>
            </h2>
            <div class="subfild-content base-info">
            	<div class="kv-item ue-clear">
                	<label><span class="impInfo">*</span>课程名称</label>
                	<div class="kv-item-content">
                    	<input type="text" placeholder="课程名称" id="name" name="name"/>
                    </div>
                </div>
                <div class="kv-item ue-clear">
                	<label><span class="impInfo">*</span>备注</label>
                	<div class="kv-item-content">
                    	<textarea name="mark" placeholder="备注" id="content" style="width:357px;height:100px;"></textarea>
                    </div>
                </div>
            </div>
            
        </div>
        
    </div>
</div>
</div>
</body>

<script type="text/javascript">
	$('select').select();
	$('#grid').datagrid({
		url:'<%=request.getContextPath()%>/manager/role/role.do?reqCode=findRoles',
		columns:[[
			{field:'id',title:'编号',checkbox:true,width:80,
				 styler:function(v,r,i){
				 	return "color:red";
				 }
			},
			{field:'name',title:'角色名称',width:150},
			{field:'desc',title:'描述',width:200},
			{field:'_op',title:'操作',width:100,
				formatter:function(v,r,i){
					var s = "<a href='javascript:;' onclick=";
					s+="'remove(";
					s+=r.id;
					s+=")'";
					s+=">删除</a>";
					return s;
				}
			}
		]],
		
    	pagination:true,
    	
    	loadMsg:'正在加载，请稍后……'
	});
	
	function remove(id){
		alert(id);
		//发起Ajax请求进行删除操作
		$.ajax({
			url:'<%=request.getContextPath()%>/manager/role/role.do',
			type:'post',
			data:{id:id,reqCode:'delRole'},
			success:function(data){
				$('#grid').datagrid('reload');
			},
			error:function(){
				
			}
		});
	}
	
	$('.search-box input[type=radio]').click(function(e) {
        if($(this).prop('checked')){
			if($(this).attr('data-define') === 'define'){
				$('.define-input').show();
			}else{
				$('.define-input').hide();
			}
		}
    });
    //根据条件查询角色
    $('input[type=button]').click(function(){
    	var v = $('#roleName').val();
    	
    	$('#grid').datagrid('load',{
    		rolename:v
    	});
    });
    
    
    $('#dd').dialog({    
	    title: '新增课程',    
	    width: 600,    
	    height: 300,    
	    closed: true,    
	    cache: false,    
	    modal: true ,
	    buttons:[{
				text:'保存',
				handler:function(){
					//添加操作
					$('#dd').dialog('close');
				}
			}]  
	});  
	
	$('a.add').click(function(){
		$('#dd').dialog('open');
	});
	$('a.delete').click(function(){
		var rows= $('#grid').datagrid('getSelections');
		var ids="";
		for(var i=0;i<rows.length;i++){
			ids+=rows[i].id;
			ids+=",";
		}
		$.ajax({
			url:'<%=request.getContextPath()%>/manager/course/course.do',
			data:{ids:ids,reqCode:'delCourses'},
			type:'post',
			success:function(data){
				$.messager.alert('提示',data.msg);
				$('#grid').datagrid('reload'); 
			}
		});
	});
</script>
</html>
